package c.e.a.c.t;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.Region.Op;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable.ConstantState;
import android.os.Build.VERSION;
import android.util.Log;
import c.e.a.c.t.m.f;
import com.pgl.sys.ces.out.ISdkLite;
import java.util.BitSet;
import java.util.Objects;

/* compiled from: MaterialShapeDrawable */
public class g extends Drawable implements b.i.d.l.a, n {
    public static final String w = g.class.getSimpleName();
    public static final Paint x = new Paint(1);
    public b a;
    public final f[] b;
    public final f[] c;
    public final BitSet d;
    public boolean e;
    public final Matrix f;
    public final Path g;
    public final Path h;
    public final RectF i;
    public final RectF j;
    public final Region k;
    public final Region l;
    public j m;
    public final Paint n;
    public final Paint o;
    public final c.e.a.c.s.a p;
    public final c.e.a.c.t.k.a q;
    public final k r;
    public PorterDuffColorFilter s;
    public PorterDuffColorFilter t;
    public final RectF u;
    public boolean v;

    /* compiled from: MaterialShapeDrawable */
    public static final class b extends ConstantState {
        public j a;
        public c.e.a.c.m.a b;
        public ColorFilter c;
        public ColorStateList d = null;
        public ColorStateList e = null;
        public ColorStateList f = null;
        public ColorStateList g = null;
        public Mode h = Mode.SRC_IN;
        public Rect i = null;
        public float j = 1.0f;
        public float k = 1.0f;
        public float l;
        public int m = ISdkLite.REGION_UNSET;
        public float n = 0.0f;
        public float o = 0.0f;
        public float p = 0.0f;
        public int q = 0;
        public int r = 0;
        public int s = 0;
        public int t = 0;
        public boolean u = false;
        public Style v = Style.FILL_AND_STROKE;

        public b(j jVar, c.e.a.c.m.a aVar) {
            this.a = jVar;
            this.b = null;
        }

        public int getChangingConfigurations() {
            return 0;
        }

        public Drawable newDrawable() {
            g gVar = new g(this);
            gVar.e = true;
            return gVar;
        }

        public b(b bVar) {
            this.a = bVar.a;
            this.b = bVar.b;
            this.l = bVar.l;
            this.c = bVar.c;
            this.d = bVar.d;
            this.e = bVar.e;
            this.h = bVar.h;
            this.g = bVar.g;
            this.m = bVar.m;
            this.j = bVar.j;
            this.s = bVar.s;
            this.q = bVar.q;
            this.u = bVar.u;
            this.k = bVar.k;
            this.n = bVar.n;
            this.o = bVar.o;
            this.p = bVar.p;
            this.r = bVar.r;
            this.t = bVar.t;
            this.f = bVar.f;
            this.v = bVar.v;
            if (bVar.i != null) {
                this.i = new Rect(bVar.i);
            }
        }
    }

    /* compiled from: MaterialShapeDrawable */
    public class a implements c.e.a.c.t.k.a {
    }

    public g() {
        this(new j());
    }

    public final void b(RectF rectF, Path path) {
        c(rectF, path);
        if (this.a.j != 1.0f) {
            this.f.reset();
            Matrix matrix = this.f;
            float f = this.a.j;
            matrix.setScale(f, f, rectF.width() / 2.0f, rectF.height() / 2.0f);
            path.transform(this.f);
        }
        path.computeBounds(this.u, true);
    }

    public final void c(RectF rectF, Path path) {
        k kVar = this.r;
        b bVar = this.a;
        j jVar = bVar.a;
        float f = bVar.k;
        kVar.a(jVar, f, rectF, this.q, path);
    }

    public final PorterDuffColorFilter d(ColorStateList colorStateList, Mode mode, Paint paint, boolean z) {
        int color;
        if (colorStateList == null || mode == null) {
            PorterDuffColorFilter porterDuffColorFilter;
            if (z) {
                color = paint.getColor();
                int e = e(color);
                if (e != color) {
                    porterDuffColorFilter = new PorterDuffColorFilter(e, Mode.SRC_IN);
                    return porterDuffColorFilter;
                }
            }
            porterDuffColorFilter = null;
            return porterDuffColorFilter;
        }
        color = colorStateList.getColorForState(getState(), 0);
        if (z) {
            color = e(color);
        }
        return new PorterDuffColorFilter(color, mode);
    }

    /* JADX WARNING: Removed duplicated region for block: B:32:0x00fa  */
    /* JADX WARNING: Removed duplicated region for block: B:45:0x01a0  */
    /* JADX WARNING: Removed duplicated region for block: B:48:0x01b5  */
    /* JADX WARNING: Missing block: B:28:0x00f1, code skipped:
            if (r2 != null) goto L_0x00f3;
     */
    public void draw(android.graphics.Canvas r13) {
        /*
        r12 = this;
        r0 = r12.n;
        r1 = r12.s;
        r0.setColorFilter(r1);
        r0 = r12.n;
        r0 = r0.getAlpha();
        r1 = r12.n;
        r2 = r12.a;
        r2 = r2.m;
        r3 = r2 >>> 7;
        r2 = r2 + r3;
        r2 = r2 * r0;
        r2 = r2 >>> 8;
        r1.setAlpha(r2);
        r1 = r12.o;
        r2 = r12.t;
        r1.setColorFilter(r2);
        r1 = r12.o;
        r2 = r12.a;
        r2 = r2.l;
        r1.setStrokeWidth(r2);
        r1 = r12.o;
        r1 = r1.getAlpha();
        r2 = r12.o;
        r3 = r12.a;
        r3 = r3.m;
        r4 = r3 >>> 7;
        r3 = r3 + r4;
        r3 = r3 * r1;
        r3 = r3 >>> 8;
        r2.setAlpha(r3);
        r2 = r12.e;
        r3 = 0;
        if (r2 == 0) goto L_0x00c6;
    L_0x0048:
        r2 = r12.k();
        r2 = -r2;
        r4 = r12.a;
        r4 = r4.a;
        java.util.Objects.requireNonNull(r4);
        r5 = new c.e.a.c.t.j$b;
        r5.m1631init(r4);
        r6 = r4.e;
        r7 = r6 instanceof c.e.a.c.t.h;
        if (r7 == 0) goto L_0x0060;
    L_0x005f:
        goto L_0x0066;
    L_0x0060:
        r7 = new c.e.a.c.t.b;
        r7.m6012init(r2, r6);
        r6 = r7;
    L_0x0066:
        r5.e = r6;
        r6 = r4.f;
        r7 = r6 instanceof c.e.a.c.t.h;
        if (r7 == 0) goto L_0x006f;
    L_0x006e:
        goto L_0x0075;
    L_0x006f:
        r7 = new c.e.a.c.t.b;
        r7.m6012init(r2, r6);
        r6 = r7;
    L_0x0075:
        r5.f = r6;
        r6 = r4.h;
        r7 = r6 instanceof c.e.a.c.t.h;
        if (r7 == 0) goto L_0x007e;
    L_0x007d:
        goto L_0x0084;
    L_0x007e:
        r7 = new c.e.a.c.t.b;
        r7.m6012init(r2, r6);
        r6 = r7;
    L_0x0084:
        r5.h = r6;
        r4 = r4.g;
        r6 = r4 instanceof c.e.a.c.t.h;
        if (r6 == 0) goto L_0x008d;
    L_0x008c:
        goto L_0x0093;
    L_0x008d:
        r6 = new c.e.a.c.t.b;
        r6.m6012init(r2, r4);
        r4 = r6;
    L_0x0093:
        r5.g = r4;
        r7 = r5.a();
        r12.m = r7;
        r6 = r12.r;
        r2 = r12.a;
        r8 = r2.k;
        r2 = r12.j;
        r4 = r12.h();
        r2.set(r4);
        r2 = r12.k();
        r4 = r12.j;
        r4.inset(r2, r2);
        r9 = r12.j;
        r11 = r12.h;
        r10 = 0;
        r6.a(r7, r8, r9, r10, r11);
        r2 = r12.h();
        r4 = r12.g;
        r12.b(r2, r4);
        r12.e = r3;
    L_0x00c6:
        r2 = r12.a;
        r4 = r2.q;
        r5 = 2;
        r6 = 1;
        if (r4 == r6) goto L_0x00f5;
    L_0x00ce:
        r7 = r2.r;
        if (r7 <= 0) goto L_0x00f5;
    L_0x00d2:
        if (r4 == r5) goto L_0x00f3;
    L_0x00d4:
        r4 = android.os.Build.VERSION.SDK_INT;
        r2 = r2.a;
        r7 = r12.h();
        r2 = r2.d(r7);
        if (r2 != 0) goto L_0x00f0;
    L_0x00e2:
        r2 = r12.g;
        r2 = r2.isConvex();
        if (r2 != 0) goto L_0x00f0;
    L_0x00ea:
        r2 = 29;
        if (r4 >= r2) goto L_0x00f0;
    L_0x00ee:
        r2 = 1;
        goto L_0x00f1;
    L_0x00f0:
        r2 = 0;
    L_0x00f1:
        if (r2 == 0) goto L_0x00f5;
    L_0x00f3:
        r2 = 1;
        goto L_0x00f6;
    L_0x00f5:
        r2 = 0;
    L_0x00f6:
        if (r2 != 0) goto L_0x00fa;
    L_0x00f8:
        goto L_0x0191;
    L_0x00fa:
        r13.save();
        r2 = r12.i();
        r4 = r12.j();
        r2 = (float) r2;
        r4 = (float) r4;
        r13.translate(r2, r4);
        r2 = r12.v;
        if (r2 != 0) goto L_0x0116;
    L_0x010e:
        r12.f(r13);
        r13.restore();
        goto L_0x0191;
    L_0x0116:
        r2 = r12.u;
        r2 = r2.width();
        r4 = r12.getBounds();
        r4 = r4.width();
        r4 = (float) r4;
        r2 = r2 - r4;
        r2 = (int) r2;
        r4 = r12.u;
        r4 = r4.height();
        r7 = r12.getBounds();
        r7 = r7.height();
        r7 = (float) r7;
        r4 = r4 - r7;
        r4 = (int) r4;
        if (r2 < 0) goto L_0x01df;
    L_0x013a:
        if (r4 < 0) goto L_0x01df;
    L_0x013c:
        r7 = r12.u;
        r7 = r7.width();
        r7 = (int) r7;
        r8 = r12.a;
        r8 = r8.r;
        r8 = r8 * 2;
        r8 = r8 + r7;
        r8 = r8 + r2;
        r7 = r12.u;
        r7 = r7.height();
        r7 = (int) r7;
        r9 = r12.a;
        r9 = r9.r;
        r9 = r9 * 2;
        r9 = r9 + r7;
        r9 = r9 + r4;
        r5 = android.graphics.Bitmap.Config.ARGB_8888;
        r5 = android.graphics.Bitmap.createBitmap(r8, r9, r5);
        r7 = new android.graphics.Canvas;
        r7.<init>(r5);
        r8 = r12.getBounds();
        r8 = r8.left;
        r9 = r12.a;
        r9 = r9.r;
        r8 = r8 - r9;
        r8 = r8 - r2;
        r2 = (float) r8;
        r8 = r12.getBounds();
        r8 = r8.top;
        r9 = r12.a;
        r9 = r9.r;
        r8 = r8 - r9;
        r8 = r8 - r4;
        r4 = (float) r8;
        r8 = -r2;
        r9 = -r4;
        r7.translate(r8, r9);
        r12.f(r7);
        r7 = 0;
        r13.drawBitmap(r5, r2, r4, r7);
        r5.recycle();
        r13.restore();
    L_0x0191:
        r2 = r12.a;
        r4 = r2.v;
        r5 = android.graphics.Paint.Style.FILL_AND_STROKE;
        if (r4 == r5) goto L_0x019d;
    L_0x0199:
        r5 = android.graphics.Paint.Style.FILL;
        if (r4 != r5) goto L_0x019e;
    L_0x019d:
        r3 = 1;
    L_0x019e:
        if (r3 == 0) goto L_0x01af;
    L_0x01a0:
        r6 = r12.n;
        r7 = r12.g;
        r8 = r2.a;
        r9 = r12.h();
        r4 = r12;
        r5 = r13;
        r4.g(r5, r6, r7, r8, r9);
    L_0x01af:
        r2 = r12.m();
        if (r2 == 0) goto L_0x01d4;
    L_0x01b5:
        r5 = r12.o;
        r6 = r12.h;
        r7 = r12.m;
        r2 = r12.j;
        r3 = r12.h();
        r2.set(r3);
        r2 = r12.k();
        r3 = r12.j;
        r3.inset(r2, r2);
        r8 = r12.j;
        r3 = r12;
        r4 = r13;
        r3.g(r4, r5, r6, r7, r8);
    L_0x01d4:
        r13 = r12.n;
        r13.setAlpha(r0);
        r13 = r12.o;
        r13.setAlpha(r1);
        return;
    L_0x01df:
        r13 = new java.lang.IllegalStateException;
        r0 = "Invalid shadow bounds. Check that the treatments result in a valid path.";
        r13.<init>(r0);
        throw r13;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.c.t.g.draw(android.graphics.Canvas):void");
    }

    public final int e(int i) {
        b bVar = this.a;
        float f = (bVar.o + bVar.p) + bVar.n;
        c.e.a.c.m.a aVar = bVar.b;
        if (aVar == null || !aVar.a) {
            return i;
        }
        if ((b.i.d.a.c(i, ISdkLite.REGION_UNSET) == aVar.c ? 1 : null) == null) {
            return i;
        }
        float f2 = aVar.d;
        float f3 = 0.0f;
        if (f2 > 0.0f && f > 0.0f) {
            f3 = Math.min(((((float) Math.log1p((double) (f / f2))) * 4.5f) + 2.0f) / 100.0f, 1.0f);
        }
        return b.i.d.a.c(c.e.a.c.a.n(b.i.d.a.c(i, ISdkLite.REGION_UNSET), aVar.b, f3), Color.alpha(i));
    }

    public final void f(Canvas canvas) {
        int i;
        if (this.d.cardinality() > 0) {
            Log.w(w, "Compatibility shadow requested but can't be drawn for all operations in this shape.");
        }
        if (this.a.s != 0) {
            canvas.drawPath(this.g, this.p.a);
        }
        for (i = 0; i < 4; i++) {
            f fVar = this.b[i];
            c.e.a.c.s.a aVar = this.p;
            int i2 = this.a.r;
            Matrix matrix = f.a;
            fVar.a(matrix, aVar, i2, canvas);
            this.c[i].a(matrix, this.p, this.a.r, canvas);
        }
        if (this.v) {
            i = i();
            int j = j();
            canvas.translate((float) (-i), (float) (-j));
            canvas.drawPath(this.g, x);
            canvas.translate((float) i, (float) j);
        }
    }

    public final void g(Canvas canvas, Paint paint, Path path, j jVar, RectF rectF) {
        if (jVar.d(rectF)) {
            float a = jVar.f.a(rectF) * this.a.k;
            canvas.drawRoundRect(rectF, a, a, paint);
            return;
        }
        canvas.drawPath(path, paint);
    }

    public ConstantState getConstantState() {
        return this.a;
    }

    public int getOpacity() {
        return -3;
    }

    @TargetApi(21)
    public void getOutline(Outline outline) {
        b bVar = this.a;
        if (bVar.q != 2) {
            if (bVar.a.d(h())) {
                outline.setRoundRect(getBounds(), l() * this.a.k);
                return;
            }
            b(h(), this.g);
            if (this.g.isConvex() || VERSION.SDK_INT >= 29) {
                try {
                    outline.setConvexPath(this.g);
                } catch (IllegalArgumentException unused) {
                }
            }
        }
    }

    public boolean getPadding(Rect rect) {
        Rect rect2 = this.a.i;
        if (rect2 == null) {
            return super.getPadding(rect);
        }
        rect.set(rect2);
        return true;
    }

    public Region getTransparentRegion() {
        this.k.set(getBounds());
        b(h(), this.g);
        this.l.setPath(this.g, this.k);
        this.k.op(this.l, Op.DIFFERENCE);
        return this.k;
    }

    public RectF h() {
        this.i.set(getBounds());
        return this.i;
    }

    public int i() {
        b bVar = this.a;
        return (int) (Math.sin(Math.toRadians((double) bVar.t)) * ((double) bVar.s));
    }

    public void invalidateSelf() {
        this.e = true;
        super.invalidateSelf();
    }

    public boolean isStateful() {
        if (!super.isStateful()) {
            ColorStateList colorStateList = this.a.g;
            if (colorStateList == null || !colorStateList.isStateful()) {
                colorStateList = this.a.f;
                if (colorStateList == null || !colorStateList.isStateful()) {
                    colorStateList = this.a.e;
                    if (colorStateList == null || !colorStateList.isStateful()) {
                        colorStateList = this.a.d;
                        if (colorStateList == null || !colorStateList.isStateful()) {
                            return false;
                        }
                    }
                }
            }
        }
        return true;
    }

    public int j() {
        b bVar = this.a;
        return (int) (Math.cos(Math.toRadians((double) bVar.t)) * ((double) bVar.s));
    }

    public final float k() {
        return m() ? this.o.getStrokeWidth() / 2.0f : 0.0f;
    }

    public float l() {
        return this.a.a.e.a(h());
    }

    public final boolean m() {
        Style style = this.a.v;
        return (style == Style.FILL_AND_STROKE || style == Style.STROKE) && this.o.getStrokeWidth() > 0.0f;
    }

    public Drawable mutate() {
        this.a = new b(this.a);
        return this;
    }

    public void n(Context context) {
        this.a.b = new c.e.a.c.m.a(context);
        w();
    }

    public void o(float f) {
        b bVar = this.a;
        if (bVar.o != f) {
            bVar.o = f;
            w();
        }
    }

    public void onBoundsChange(Rect rect) {
        this.e = true;
        super.onBoundsChange(rect);
    }

    public boolean onStateChange(int[] iArr) {
        boolean z = u(iArr) || v();
        if (z) {
            invalidateSelf();
        }
        return z;
    }

    public void p(ColorStateList colorStateList) {
        b bVar = this.a;
        if (bVar.d != colorStateList) {
            bVar.d = colorStateList;
            onStateChange(getState());
        }
    }

    public void q(float f) {
        b bVar = this.a;
        if (bVar.k != f) {
            bVar.k = f;
            this.e = true;
            invalidateSelf();
        }
    }

    public void r(float f, int i) {
        this.a.l = f;
        invalidateSelf();
        t(ColorStateList.valueOf(i));
    }

    public void s(float f, ColorStateList colorStateList) {
        this.a.l = f;
        invalidateSelf();
        t(colorStateList);
    }

    public void setAlpha(int i) {
        b bVar = this.a;
        if (bVar.m != i) {
            bVar.m = i;
            super.invalidateSelf();
        }
    }

    public void setColorFilter(ColorFilter colorFilter) {
        this.a.c = colorFilter;
        super.invalidateSelf();
    }

    public void setShapeAppearanceModel(j jVar) {
        this.a.a = jVar;
        invalidateSelf();
    }

    public void setTint(int i) {
        setTintList(ColorStateList.valueOf(i));
    }

    public void setTintList(ColorStateList colorStateList) {
        this.a.g = colorStateList;
        v();
        super.invalidateSelf();
    }

    public void setTintMode(Mode mode) {
        b bVar = this.a;
        if (bVar.h != mode) {
            bVar.h = mode;
            v();
            super.invalidateSelf();
        }
    }

    public void t(ColorStateList colorStateList) {
        b bVar = this.a;
        if (bVar.e != colorStateList) {
            bVar.e = colorStateList;
            onStateChange(getState());
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:8:0x0025  */
    public final boolean u(int[] r5) {
        /*
        r4 = this;
        r0 = r4.a;
        r0 = r0.d;
        r1 = 1;
        if (r0 == 0) goto L_0x001e;
    L_0x0007:
        r0 = r4.n;
        r0 = r0.getColor();
        r2 = r4.a;
        r2 = r2.d;
        r2 = r2.getColorForState(r5, r0);
        if (r0 == r2) goto L_0x001e;
    L_0x0017:
        r0 = r4.n;
        r0.setColor(r2);
        r0 = 1;
        goto L_0x001f;
    L_0x001e:
        r0 = 0;
    L_0x001f:
        r2 = r4.a;
        r2 = r2.e;
        if (r2 == 0) goto L_0x003b;
    L_0x0025:
        r2 = r4.o;
        r2 = r2.getColor();
        r3 = r4.a;
        r3 = r3.e;
        r5 = r3.getColorForState(r5, r2);
        if (r2 == r5) goto L_0x003b;
    L_0x0035:
        r0 = r4.o;
        r0.setColor(r5);
        goto L_0x003c;
    L_0x003b:
        r1 = r0;
    L_0x003c:
        return r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.c.t.g.u(int[]):boolean");
    }

    public final boolean v() {
        PorterDuffColorFilter porterDuffColorFilter = this.s;
        PorterDuffColorFilter porterDuffColorFilter2 = this.t;
        b bVar = this.a;
        this.s = d(bVar.g, bVar.h, this.n, true);
        bVar = this.a;
        this.t = d(bVar.f, bVar.h, this.o, false);
        bVar = this.a;
        if (bVar.u) {
            this.p.a(bVar.g.getColorForState(getState(), 0));
        }
        if (Objects.equals(porterDuffColorFilter, this.s) && Objects.equals(porterDuffColorFilter2, this.t)) {
            return false;
        }
        return true;
    }

    public final void w() {
        b bVar = this.a;
        float f = bVar.o + bVar.p;
        bVar.r = (int) Math.ceil((double) (0.75f * f));
        this.a.s = (int) Math.ceil((double) (f * 0.25f));
        v();
        super.invalidateSelf();
    }

    public g(j jVar) {
        this(new b(jVar, null));
    }

    public g(b bVar) {
        this.b = new f[4];
        this.c = new f[4];
        this.d = new BitSet(8);
        this.f = new Matrix();
        this.g = new Path();
        this.h = new Path();
        this.i = new RectF();
        this.j = new RectF();
        this.k = new Region();
        this.l = new Region();
        Paint paint = new Paint(1);
        this.n = paint;
        Paint paint2 = new Paint(1);
        this.o = paint2;
        this.p = new c.e.a.c.s.a();
        this.r = new k();
        this.u = new RectF();
        this.v = true;
        this.a = bVar;
        paint2.setStyle(Style.STROKE);
        paint.setStyle(Style.FILL);
        Paint paint3 = x;
        paint3.setColor(-1);
        paint3.setXfermode(new PorterDuffXfermode(Mode.DST_OUT));
        v();
        u(getState());
        this.q = new a();
    }
}
